

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=&#34;auto&#34;>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/2.jpg">
  <link rel="icon" type="image/png" href="/img/2.jpg">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="description" content="">
  <meta name="author" content="K">
  <meta name="keywords" content="">
  <title>python-文件 - K</title>

  <link  rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.staticfile.org/github-markdown-css/4.0.0/github-markdown.min.css" />
  <link  rel="stylesheet" href="/lib/hint/hint.min.css" />

  
    
    
      
      <link  rel="stylesheet" href="https://cdn.staticfile.org/highlight.js/10.0.0/styles/github-gist.min.css" />
    
  

  


<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_ba1fz6golrf.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_kmeydafke9r.css">


<link  rel="stylesheet" href="/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
<meta name="generator" content="Hexo 5.2.0"></head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/">&nbsp;<strong>かい</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;</a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" href="javascript:">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner intro-2" id="background" parallax=true
         style="background: url('/img/1.jpg') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="container page-header text-center fade-in-up">
            <span class="h2" id="subtitle">
              
            </span>

            
              <div class="mt-3">
  
  
    <span class="post-meta">
      <i class="iconfont icon-date-fill" aria-hidden="true"></i>
      <time datetime="2020-09-02 10:32" pubdate>
        2020年9月2日 上午
      </time>
    </span>
  
</div>

<div class="mt-1">
  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      1.8k 字
    </span>
  

  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      22
       分钟
    </span>
  

  
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid">
  <div class="row">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-md">
      <div class="container nopadding-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto" id="post">
            <!-- SEO header -->
            <h1 style="display: none">python-文件</h1>
            
            <div class="markdown-body" id="post-body">
              <h2 id="文件"><a href="#文件" class="headerlink" title="文件"></a>文件</h2><ul>
<li><p>通python程序来对计算机中的各个文件进行增删改查的操作</p>
</li>
<li><p>在其他语言中有称为 I/O（input / output），在python中就称为文件（file）</p>
</li>
<li><p>操作文件的步骤：</p>
<blockquote>
<p>打开文件<br>对文件进行各种操作（读，写）然后保存<br>关闭文件</p>
</blockquote>
</li>
</ul>
<h2 id="打开文件"><a href="#打开文件" class="headerlink" title="打开文件"></a>打开文件</h2><ul>
<li><p>open()函数用来打开文件</p>
</li>
<li><p>参数：</p>
<blockquote>
<p>()里有一个位置参数和多个关键字参数<br>file 位置参数 是 大开文件的路径<br>mode 读还是写操作<br>encoding = 指定的字符编码</p>
</blockquote>
</li>
<li><p>返回值：</p>
<ul>
<li>返回一个对象，这个对象就代表了当前打开的文件</li>
</ul>
</li>
</ul>
<pre><code class="hljs routeros">例:
file = open(<span class="hljs-string">&#x27;./hhh.txt&#x27;</span>,<span class="hljs-string">&#x27;w&#x27;</span>,encoding = <span class="hljs-string">&#x27;utf-8&#x27;</span>)
<span class="hljs-comment"># 用file这个对象来接收open()的返回值</span>
		
<span class="hljs-builtin-name">print</span>(file)
	
<span class="hljs-comment"># 输出结果</span>
	# &lt;_io.TextIOWrapper <span class="hljs-attribute">name</span>=<span class="hljs-string">&#x27;./hhh.txt&#x27;</span> <span class="hljs-attribute">mode</span>=<span class="hljs-string">&#x27;w&#x27;</span> <span class="hljs-attribute">encoding</span>=<span class="hljs-string">&#x27;utf-8&#x27;</span>&gt;</code></pre>

<h2 id="关闭文件"><a href="#关闭文件" class="headerlink" title="关闭文件"></a>关闭文件</h2><ul>
<li><p>接上面的已经打开文件了</p>
</li>
<li><p>lose()</p>
<blockquote>
<p>这个函数用来关闭文件</p>
</blockquote>
</li>
<li><p>如果是这样写的话每次调用都要手动关闭文件，有的时候可能会忘掉，可以用以下方法</p>
<pre><div class="caption"><span>... as``` 语句</span></div><code class="hljs with">&#96;&#96;&#96;
例：
with open(&#39;hhh.txt&#39;,&#39;w&#39;,encoding&#x3D;&#39;utf-8&#39;) as file :
	print(file)
	# 这个输出结果还是
	# &lt;_io.TextIOWrapper name&#x3D;&#39;hhh.txt&#39; mode&#x3D;&#39;w&#39; encoding&#x3D;&#39;utf-8&#39;&gt;
		
	# as 后面的file 就是 通过 前面的 with 把 open()这个返回值赋值给 file这个对象中
	# 在这个语句的下一级进行的操作都是对file这个对象进行的操作
	# file这个对象就是打开的文件,可以这样理解

	# 在with语句结束时文件会自动的colse()</code></pre>
<pre><code class="hljs python">例:
file_name = <span class="hljs-string">&#x27;hello&#x27;</span>

<span class="hljs-keyword">try</span>:
	<span class="hljs-keyword">with</span> <span class="hljs-built_in">open</span>(file_name) <span class="hljs-keyword">as</span> file_obj :
		print(file_obj.read())
<span class="hljs-keyword">except</span> FileNotFoundError:
	print(<span class="hljs-string">f&#x27;<span class="hljs-subst">&#123;file_name&#125;</span> 文件不存在~~&#x27;</span>)

	<span class="hljs-comment"># 可以通过try语句来对这个语句进行异常捕获</span>
    <span class="hljs-comment"># 如果系统内该文件不存在就打不开，然后报错，通过捕获异常来解决或者提醒</span>
</code></pre>

</li>
</ul>
<h2 id="读取文件"><a href="#读取文件" class="headerlink" title="读取文件"></a>读取文件</h2><ul>
<li><p>调用open()函数来打开一个文件，可以将文件分成两种类型</p>
</li>
<li><p>一种 纯文本文件（使用utf-8等编码编写的文本文件）</p>
</li>
<li><p>一种 二进制文件（图片，音乐，视频等文件）</p>
</li>
<li><p>open()打开文件时，默认是以文本文件的形式打开的，但是open()默认的编码为None 就是 encodig = None</p>
</li>
<li><p>所以处理文本文件时，必须要指定文件的编码</p>
</li>
<li><p>read()</p>
<ul>
<li><p>通过read()来读取内容</p>
</li>
<li><p>如果直接调用read()会将文件内的所有内容全部读取出来</p>
</li>
<li><p>这时如果文件比较大的话，会一次性将文件的内容都加载到内存中，容易导致内存泄漏</p>
</li>
<li><p>所以对于比较大的文件不要直接调用read()</p>
</li>
<li><p>read()可以接受一个size作为参数，该参数用来指定要读取的字符数量</p>
</li>
<li><p>默认值是-1，也就是全部读取</p>
</li>
<li><p>可以为size指定一个值，这样read()会读取指定数量的字符</p>
</li>
<li><p>每一次读取都是从上次读取到的位置开始读取的</p>
</li>
<li><p>如果字符的数量小于size，则会读取剩余所有的</p>
</li>
<li><p>如果已经读取到了文件的最后了，则会返回 ‘ ‘空字符串</p>
<pre><code class="hljs livecodeserver">例:
		
<span class="hljs-comment"># 写入文件的with语句</span>
<span class="hljs-keyword">with</span> <span class="hljs-built_in">open</span>(<span class="hljs-string">&#x27;hhh.txt&#x27;</span>,<span class="hljs-string">&#x27;w&#x27;</span>,encoding=<span class="hljs-string">&#x27;utf-8&#x27;</span>) <span class="hljs-keyword">as</span> <span class="hljs-built_in">file</span> :
	<span class="hljs-comment"># 这是写入文件，现在先不深究</span>
	<span class="hljs-built_in">file</span>.<span class="hljs-built_in">write</span>(<span class="hljs-string">&#x27;hhh,hello,python\n&#x27;</span>)
	<span class="hljs-built_in">file</span>.<span class="hljs-built_in">write</span>(<span class="hljs-string">&#x27;hhh,hello,world\n&#x27;</span>)
	<span class="hljs-built_in">file</span>.<span class="hljs-built_in">write</span>(<span class="hljs-string">&#x27;hhh,hello,lmk\n&#x27;</span>)
	<span class="hljs-built_in">file</span>.<span class="hljs-built_in">write</span>(<span class="hljs-string">&#x27;hhh,hello,genji\n&#x27;</span>)

<span class="hljs-comment"># 读取文件的with语句</span>
<span class="hljs-keyword">with</span> <span class="hljs-built_in">open</span>(<span class="hljs-string">&#x27;hhh.txt&#x27;</span>,<span class="hljs-string">&#x27;r&#x27;</span>,encoding=<span class="hljs-string">&#x27;utf-8&#x27;</span>)<span class="hljs-keyword">as</span> <span class="hljs-built_in">file</span>:
	<span class="hljs-comment"># 一次性读取16个字符</span>
	print(<span class="hljs-built_in">file</span>.<span class="hljs-built_in">read</span>(<span class="hljs-number">16</span>))
	print(<span class="hljs-built_in">file</span>.<span class="hljs-built_in">read</span>(<span class="hljs-number">16</span>))
	print(<span class="hljs-built_in">file</span>.<span class="hljs-built_in">read</span>(<span class="hljs-number">16</span>))
	print(<span class="hljs-built_in">file</span>.<span class="hljs-built_in">read</span>(<span class="hljs-number">16</span>))</code></pre>
<pre><code class="hljs vim">例:
定义一个循环用来读取文件的内容	
with <span class="hljs-keyword">open</span>(<span class="hljs-string">&#x27;hhh.txt&#x27;</span>,<span class="hljs-string">&#x27;r&#x27;</span>,encoding=<span class="hljs-string">&#x27;utf-8&#x27;</span>) <span class="hljs-keyword">as</span> <span class="hljs-keyword">file</span>:
	<span class="hljs-keyword">b</span> = <span class="hljs-string">&#x27;&#x27;</span>
	<span class="hljs-keyword">while</span> True:
		<span class="hljs-keyword">c</span> = <span class="hljs-keyword">file</span>.<span class="hljs-keyword">read</span>(<span class="hljs-number">1024</span>)        
		<span class="hljs-keyword">if</span> not <span class="hljs-keyword">c</span>:
		    <span class="hljs-keyword">break</span>
		<span class="hljs-keyword">b</span> += <span class="hljs-keyword">c</span>
<span class="hljs-keyword">print</span>(<span class="hljs-keyword">b</span>)</code></pre>
</li>
<li><p>readline()</p>
<blockquote>
<p>该方法可以用来读取一行内容<br>和read()差不多</p>
</blockquote>
</li>
<li><p>readlines()</p>
<blockquote>
<p>该方法用于一行一行的读取内容，并且会一次性将读取到的内容封装到一个列表中返回</p>
</blockquote>
</li>
</ul>
</li>
</ul>
<h2 id="文件的写入"><a href="#文件的写入" class="headerlink" title="文件的写入"></a>文件的写入</h2><ul>
<li><p>使用open()打开文件时必须要指定打开文件所需要的操作，（读，写，追加）</p>
</li>
<li><p>如果不能指定操作类型，则默认是读取文件，而读取文件时，是不能向文件中写入的</p>
<blockquote>
<p>r 表示只读<br> w 表示可写的，使用w来写入文件时，如果文件不存在会创建该文件，如果存在就会清空重新写<br> a 表示追加内容 如果问阿金不存在会创建文件，如果文件存在则会向文件中追加内容<br> x 用来新建文件，如果文件不存在则创建，存在则报错</p>
</blockquote>
<ul>
<li>+ 为操作符增加功能<blockquote>
<p>r+ 即可读又可写<br>w+ 在写中加入了读的功能<br>a+ 在追加中加入了读的功能</p>
</blockquote>
</li>
</ul>
</li>
<li><p>write()</p>
<ul>
<li>用来向文件中写入内容</li>
<li>如果操作的是一个文本文件的话，则write()需要传递一个字符串作为参数，就是要写入的内容</li>
<li>该方法会多次向文件中写入内容</li>
<li>写入完成后，该方法会返回写入的字符个数<pre><code class="hljs livecodeserver"><span class="hljs-keyword">with</span> <span class="hljs-built_in">open</span>(<span class="hljs-string">&#x27;hhh.txt&#x27;</span>,<span class="hljs-string">&#x27;w&#x27;</span>,encoding=<span class="hljs-string">&#x27;utf-8&#x27;</span>) <span class="hljs-keyword">as</span> <span class="hljs-built_in">file</span> :
	<span class="hljs-comment"># 写入文件</span>
	<span class="hljs-built_in">file</span>.<span class="hljs-built_in">write</span>(<span class="hljs-string">&#x27;hhh,hello,python\n&#x27;</span>)
	<span class="hljs-built_in">file</span>.<span class="hljs-built_in">write</span>(<span class="hljs-string">&#x27;hhh,hello,world\n&#x27;</span>)
	<span class="hljs-built_in">file</span>.<span class="hljs-built_in">write</span>(<span class="hljs-string">&#x27;hhh,hello,lmk\n&#x27;</span>)
	<span class="hljs-built_in">file</span>.<span class="hljs-built_in">write</span>(<span class="hljs-string">&#x27;hhh,hello,genji\n&#x27;</span>)
  <span class="hljs-comment"># 每次写入完成后file就会返回写入的字符串的个数（长度）</span></code></pre>
<h2 id="文件-1"><a href="#文件-1" class="headerlink" title="文件"></a>文件</h2></li>
</ul>
</li>
<li><p>读取模式</p>
<blockquote>
<p>t 读取文本文件（默认值）<br>  b 读取二进制文件</p>
</blockquote>
</li>
<li><p>读取文本文件</p>
<pre><code class="hljs livecodeserver"><span class="hljs-keyword">with</span> <span class="hljs-built_in">open</span>(<span class="hljs-string">&#x27;hhh.txt&#x27;</span>,<span class="hljs-string">&#x27;rt&#x27;</span>,encoding=<span class="hljs-string">&#x27;utf-8&#x27;</span>) <span class="hljs-keyword">as</span> <span class="hljs-built_in">file</span> :
    <span class="hljs-built_in">file</span>.<span class="hljs-built_in">read</span>(<span class="hljs-number">10</span>)
<span class="hljs-comment"># 读取文本文件时size是以字符为单位的</span>
<span class="hljs-comment"># 这里读取了10个字符</span></code></pre>


</li>
</ul>
<ul>
<li><p>读取二进制文件</p>
<pre><code class="hljs livecodeserver"><span class="hljs-keyword">with</span> <span class="hljs-built_in">open</span>(<span class="hljs-string">&#x27;hhh.txt&#x27;</span>,<span class="hljs-string">&#x27;rb&#x27;</span>) <span class="hljs-keyword">as</span> <span class="hljs-built_in">file</span> :
    <span class="hljs-built_in">file</span>.<span class="hljs-built_in">read</span>(<span class="hljs-number">1024</span>)
<span class="hljs-comment"># 读取二进制文件时size是以字节为单位的</span>
<span class="hljs-comment"># 这里读取了1024个字节 也就是 1024b</span></code></pre>
</li>
<li><p>将一个音乐文本读取然后写入到另一个文本中</p>
<pre><code class="hljs livecodeserver"><span class="hljs-keyword">a</span> = <span class="hljs-string">&#x27;C:/Users/12482/Music/キセキ - GReeeeN.ncm&#x27;</span>

<span class="hljs-keyword">with</span> <span class="hljs-built_in">open</span>(<span class="hljs-keyword">a</span>,<span class="hljs-string">&#x27;rb&#x27;</span>) <span class="hljs-keyword">as</span> <span class="hljs-built_in">file</span>:
	b = <span class="hljs-string">&#x27;aa.ncm&#x27;</span>
	<span class="hljs-keyword">with</span> <span class="hljs-built_in">open</span>(b,<span class="hljs-string">&#x27;wb&#x27;</span>) <span class="hljs-keyword">as</span> <span class="hljs-built_in">files</span>:
		<span class="hljs-keyword">while</span> True:
		    c = <span class="hljs-built_in">file</span>.<span class="hljs-built_in">read</span>(<span class="hljs-number">2048</span>)
		    <span class="hljs-keyword">if</span> <span class="hljs-keyword">not</span> c:
		        break
		    <span class="hljs-built_in">files</span>.<span class="hljs-built_in">write</span>(c)</code></pre>
</li>
<li><p>读取文件的位置</p>
<ul>
<li>seek()<blockquote>
<p>这个函数可以修改文件当前读取的位置，和光标差不多</p>
</blockquote>
</li>
</ul>
</li>
<li><p>seek() 需要两个参数</p>
<blockquote>
<p>1，要切换到的位置<br> 2，计算位置方式<br> 可选值，<br> 0，从头计算，默认值 切换到的位置当做开头<br> 1，从当前位置计算   从当前位置往后读切换的位置的数<br> 2，从最后位置开始计算</p>
</blockquote>
<pre><code class="hljs angelscript">#     file_obj.seek(<span class="hljs-number">55</span>) 从第<span class="hljs-number">55</span>个字符或字节开始读或写
#     file_obj.seek(<span class="hljs-number">80</span>,<span class="hljs-number">0</span>)  就是从 <span class="hljs-number">80</span>个字符或字节开始读或写
#     file_obj.seek(<span class="hljs-number">70</span>,<span class="hljs-number">1</span>) 从当前位置往后在读 <span class="hljs-number">70</span>个字符或字节
#     file_obj.seek(<span class="hljs-number">-10</span>,<span class="hljs-number">2</span>) 从最后十个开始读或写</code></pre></li>
<li><p>tell()</p>
<blockquote>
<p>该方法用来查看当前读取的位置</p>
</blockquote>
<pre><code class="hljs applescript">例：
	print(<span class="hljs-built_in">file</span>.<span class="hljs-keyword">tell</span>())
    <span class="hljs-comment"># 查看当前文件读取到哪里了</span></code></pre></li>
</ul>

            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                  <div class="post-meta mr-3">
                    <i class="iconfont icon-category"></i>
                    
                      <a class="hover-with-bg" href="/categories/python/">python</a>
                    
                  </div>
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/tags/python%E5%9F%BA%E7%A1%80/">python基础</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">本博客所有文章是以学习为目的，如果有不对的地方可以一起交流沟通共同学习 邮箱:1248287831@qq.com！</p>
              
              
                <div class="post-prevnext row">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2020/11/04/%E5%89%8D%E7%AB%AF%E5%B8%83%E5%B1%80-flex%E5%B8%83%E5%B1%80/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">前端布局-flex布局</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2020/09/01/python-python%E6%A8%A1%E5%9D%97%EF%BC%88os%E4%BB%A5%E5%8F%8Asys%EF%BC%89-%E6%A0%87%E5%87%86%E5%BA%93%E4%BB%A5%E5%8F%8A%E5%BC%82%E5%B8%B8%E5%A4%84%E7%90%86/">
                        <span class="hidden-mobile">python模块（os以及sys）-标准库以及异常处理</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div id="tocbot"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    
  </main>

  
    <a id="scroll-top-button" href="#" role="button">
      <i class="iconfont icon-arrowup" aria-hidden="true"></i>
    </a>
  

  
    <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
  

  

  <footer class="text-center mt-5 py-3">
  <div class="footer-content">
     <a href="https://space.bilibili.com/39165374" target="_blank" rel="nofollow noopener"><span>LMK</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
  </div>
  
  <div class="statistics">
    
    

    
      
        <!-- 不蒜子统计PV -->
        <span id="busuanzi_container_site_pv" style="display: none">
            总访问量 
            <span id="busuanzi_value_site_pv"></span>
             次
          </span>
      
      
        <!-- 不蒜子统计UV -->
        <span id="busuanzi_container_site_uv" style="display: none">
            总访客数 
            <span id="busuanzi_value_site_uv"></span>
             人
          </span>
      
    
  </div>


  

  
</footer>

<!-- SCRIPTS -->
<script  src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js" ></script>
<script  src="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/js/bootstrap.min.js" ></script>
<script  src="/js/debouncer.js" ></script>
<script  src="/js/main.js" ></script>

<!-- Plugins -->


  
    <script  src="/js/lazyload.js" ></script>
  



  



  <script defer src="https://cdn.staticfile.org/clipboard.js/2.0.6/clipboard.min.js" ></script>
  <script  src="/js/clipboard-use.js" ></script>



  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





  <script  src="https://cdn.staticfile.org/tocbot/4.11.1/tocbot.min.js" ></script>
  <script>
    $(document).ready(function () {
      var boardCtn = $('#board-ctn');
      var boardTop = boardCtn.offset().top;

      tocbot.init({
        tocSelector: '#tocbot',
        contentSelector: '#post-body',
        headingSelector: 'h1,h2,h3,h4,h5,h6',
        linkClass: 'tocbot-link',
        activeLinkClass: 'tocbot-active-link',
        listClass: 'tocbot-list',
        isCollapsedClass: 'tocbot-is-collapsed',
        collapsibleClass: 'tocbot-is-collapsible',
        collapseDepth: 0,
        scrollSmooth: true,
        headingsOffset: -boardTop
      });
      if ($('.toc-list-item').length > 0) {
        $('#toc').css('visibility', 'visible');
      }
    });
  </script>



  <script  src="https://cdn.staticfile.org/typed.js/2.0.11/typed.min.js" ></script>
  <script>
    var typed = new Typed('#subtitle', {
      strings: [
        '  ',
        "python-文件&nbsp;",
      ],
      cursorChar: "_",
      typeSpeed: 70,
      loop: false,
    });
    typed.stop();
    $(document).ready(function () {
      $(".typed-cursor").addClass("h2");
      typed.start();
    });
  </script>



  <script  src="https://cdn.staticfile.org/anchor-js/4.2.2/anchor.min.js" ></script>
  <script>
    anchors.options = {
      placement: "right",
      visible: "hover",
      
    };
    var el = "h1,h2,h3,h4,h5,h6".split(",");
    var res = [];
    for (item of el) {
      res.push(".markdown-body > " + item)
    }
    anchors.add(res.join(", "))
  </script>



  <script  src="/js/local-search.js" ></script>
  <script>
    var path = "/local-search.xml";
    var inputArea = document.querySelector("#local-search-input");
    inputArea.onclick = function () {
      searchFunc(path, 'local-search-input', 'local-search-result');
      this.onclick = null
    }
  </script>



  <script  src="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.css" />

  <script>
    $('#post img:not(.no-zoom img, img[no-zoom]), img[zoom]').each(
      function () {
        var element = document.createElement('a');
        $(element).attr('data-fancybox', 'images');
        $(element).attr('href', $(this).attr('src'));
        $(this).wrap(element);
      }
    );
  </script>















</body>
</html>
